/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package systole.processor.correlation;

import java.math.BigDecimal;
import systole.domain.signals.Segment;

/**
 *
 * @author jmj
 */
public class CorrelationBySegment extends Correlation {

    private int initPosOfCorrelation;
    private int endPosOfCorrelation;

    /**
     *
     * @param pattern
     * @throws IllegalArgumentException If pattern is null
     */
    public CorrelationBySegment(Segment pattern) {
        super(pattern);
        this.initPosOfCorrelation = this.pattern.getPosOfMax() + 10;
        this.endPosOfCorrelation = this.initPosOfCorrelation + 55;
        if (this.endPosOfCorrelation > this.pattern.size()) {
            this.endPosOfCorrelation = this.pattern.size() - 1;
        }

    }

    @Override
    public BigDecimal correlate(Segment segment) {
        return this.correlate(segment, this.initPosOfCorrelation, this.endPosOfCorrelation);
    }
}
